import java.sql.*;

public class DBConnection {

	   // JDBC driver name and database URL
	   static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";  
	   static final String DB_URL = "jdbc:mysql://localhost:3306/alert";	// CHANGE "alert" IF YOUR DATABASE NAME IS DIFFERENT

	   //  Database credentials 
	   
	   //CHANGE THIS FOR YOUR DATABASE
	   static final String USER = "root"; // put your user name
	   static final String PASS = "mysql";	// put your password
	   
	   private static Connection connection = null;

	   
	   public static Connection getConnection() throws SQLException{
		   
		   try {
	     	   // Register JDBC driver
			   Class.forName(JDBC_DRIVER).newInstance();
			   //System.out.println("Connecting to DB");
	
			   try {   
				   connection = DriverManager.getConnection(DB_URL, USER, PASS);
				   
			   } catch (Exception e) {
				   System.out.println("Could not connect to database");
     	    	  e.printStackTrace();
     	    }
     	   } catch(Exception e){
     		   System.out.println("Other exception");
     	   }
		   return connection;
	   }

		  

}
